<%@ page pageEncoding="UTF-8" %>

<c:import url="../../../template/layout.jsp" charEncoding="UTF-8">
  <c:param name="title" value="经纪人管理"/>
  <c:param name="body">
    <script>
      $(document).ready(
              function () {
                var id = $(".id").val();
                if (id) {

                }

              });
    </script>


    <div class="content-title">经纪人管理
    </div>
    <div class="container"
         style="background-color:#DCEAF4; width:1300px; height:500px;border-radius: 0px 0px 0px 0px;">
      <c:if test="${message!=null}">
        <div class="alert alert-danger" role="alert">${message.msg}</div>
      </c:if>
      <div class="btn-group pull-right" style="margin-bottom:8px;">
        <a class="btn btn-lg btn-primary" href="${pageContext.request.contextPath}/system/user/list?type=1">
          <span class="glyphicon"></span> 添加经纪人
        </a>
      </div>
      <p></p>
      <div class="main-content">

        <table class="table">
          <thead>
          <tr>
            <th>头像</th>
            <th>名称</th>
            <th>性别</th>
            <th>描述</th>
            <th>积分</th>
            <th>加入时间</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <c:forEach items="${agentList}" var="agent">
            <tr class="success">
              <td><image src="#"/></td>
              <td>${agent.agentName}</td>
              <td>
                  ${agent.sex}
              </td>
              <td>
                  ${agent.description}
              </td>
              <td>
                  ${agent.score}
              </td>
              <td>
                  ${agent.joinTime}
              </td>
              <td>
                <button onclick="editAgent('<c:url value="/system/agent/getAgent?id=${agent.id}"/>')"
                        class="btn btn-primary btn-xs"
                        data-toggle="modal" data-target="#editAgent">编辑
                </button>
                &nbsp;&nbsp;
                <button class="btn btn-primary btn-xs"
                        href="javascript:void(0)" data-toggle="tooltip" title="删除"
                        onclick="if (confirm('确认要删除本记录吗？此操作将不可恢复！'))
                                location = '<c:url
                                value="/system/agent/delete?id=${agent.id}"/>';
                                return false;">删除
                </button>


              </td>
            </tr>
          </c:forEach>
          <tr>
              <%-- <td colspan="7">
                   <jsp:include page="../inc/pager.jsp">
                       <jsp:param value="manage_userList.action" name="url"/>
                       <jsp:param value="${userPager.totalRecord }" name="items"/>
                       <jsp:param value="isRead" name="params"/>
                   </jsp:include>
               </td>--%>
          </tr>
          </tbody>
        </table>
      </div>
    </div>
    <script type="text/javascript">

      function editAgent(path) {
        $.ajax({
          url: path,
          type: 'get',
          async: true,
          dataType: 'json',
          success: function (agent) {
            $('#edit_username').val(agent.username);
            $('#edit_sex').val(agent.sex);
            $('#edit_description').val(agent.description);
            $('#edit_score').val(agent.score);
            $('#edit_id').val(agent.id);
            $('#edit_username').val(agent.agentName);
          }
        });
      }


    </script>
    <%--编辑模态框--%>
    <div class="modal fade" id="editAgent" tabindex="-1" role="dialog">
      <div class="modal-dialog modal-lg">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">
              <span aria-hidden="true">&times;</span>
              <span class="sr-only">Close</span>
            </button>
            <h3 class="modal-title">编辑</h3>
          </div>
          <div class="modal-body">
            <form name="agent" action="/system/agent/update" method="POST">
              <div class="form-group">
                <image src="#"/>
              </div>
              <div class="form-group">
                <label class="control-label" for="edit_username">用户名</label>
                <input type="text" class="form-control" id="edit_username" name="username"
                       readonly>
              </div>
              <div class="form-group">
                <label class="control-label" for="edit_sex">性别</label>
                <input type="text" class="form-control" id="edit_sex" name="sex" required>
              </div>
              <div class="form-group">
                <label for="edit_description">描述</label>
                <input class="form-control" id="edit_description" name="description" required/>
              </div>
              <div class="form-group">
                <label for="edit_score">积分</label>
                <input class="form-control" id="edit_score" name="score" required/>
              </div>
              <div class="form-group">
                <input class="form-control" type="hidden" name="id" id="edit_id"/>
              </div>
              <button class="btn btn-primary btn-lg btn-block" type="submit">
                确定
              </button>
            </form>
          </div>
        </div>
      </div>
    </div>
  </c:param>
</c:import>
